﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 原型模式深复制
{
    /// <summary>
    /// 深复制，副本对象指向一个复制过来的新对象，而不是原来对象的引用
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            TestClone();
            TestCopy();
            Console.ReadLine();
        }

        /// <summary>
        /// 浅复制
        /// </summary>
        static void TestClone()
        {
            Console.WriteLine("******浅复制******");
            Resume a = new Resume("大鸟");
            a.SetPersonalInfo("男", "29");
            a.SetWorkExperience("1998-2000", "广东公司");

            Resume b = (Resume)a.Clone();
            b.SetPersonalInfo("男", "24");
            b.SetWorkExperience("2000-2008", "华为");

            Resume c = (Resume)a.Clone();
            c.SetPersonalInfo("男", "20");
            c.SetWorkExperience("2001-2004", "腾讯");

            a.Display();
            b.Display();
            c.Display();
        }

        /// <summary>
        /// 深复制
        /// </summary>
        static void TestCopy()
        {
            Console.WriteLine("******深复制******");
            Resume a = new Resume("大鸟");
            a.SetPersonalInfo("男", "29");
            a.SetWorkExperience("1998-2000", "广东公司");

            Resume b = (Resume)a.Copy();
            b.SetPersonalInfo("男", "24");
            b.SetWorkExperience("2000-2008", "华为");

            Resume c = (Resume)a.Copy();
            c.SetPersonalInfo("男", "20");
            c.SetWorkExperience("2001-2004", "腾讯");

            a.Display();
            b.Display();
            c.Display();
        }


    }


}
